package jetbrains.buildServer.cuta.logic;

import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import java.util.ArrayList;
import java.util.List;



/**
 * Page definition.
 * @author Leonid Bushuev from JetBrains
 */
public class PageDef
{

    /**
     * Page identifier.
     * Usesages: (1) in the cuta.xml as a node identifier
     *       and (2) in urls to identify this page.
     */
    @NotNull
    public final String id;

    /**
     * What kind of objects will be shown on this page.
     */
    @NotNull
    public final CutaSheetKind kind;

    /**
     * The 1st level tab (maimn tab).
     */
    @NotNull
    public final String tab1;

    /**
     * The 2nd level tab (sub tab).
     */
    @Nullable
    public final String tab2;

    /**
     * Page title.
     */
    public String title;

    /**
     * Some page text that will be placed over the table.
     */
    public String header;

    /**
     * Some page text that will be placed below the table.
     */
    public String footer;

    /**
     * Column definitions.
     */
    public final List<ColumnDef> columns = new ArrayList<ColumnDef>();



    /**
     * Trivial constructor.
     * @param id
     * @param kind
     * @param tab
     */
    public PageDef(@NotNull String id, @NotNull CutaSheetKind kind, @NotNull String tab)
    {
        this.id = id;
        this.kind = kind;

        String[] tabs = tab.split("/", 2);
        tab1 = tabs[0].trim();
        tab2 = tabs.length == 2 ? tabs[1].trim() : null;
    }




    public String getTitle()
    {
        return title;
    }


    public String getHeader()
    {
        return header;
    }


    public String getFooter()
    {
        return footer;
    }

}
